unit cmdSetLayerTableName;

interface

uses  classes, sysutils
    , mapsXml
    , nativeXml
//    , appMappldXmlNode
    , appMappldXmlCommand
    , appMappldTypes
//    , appMappldXmlContext
    , appMappldXmlLayer
;

type
    {------------------------------ TCmdSetLayerTableName }

    {***************************************************************************
    * TCmdSetLayerTableName
    ***************************************************************************}
    TCmdSetLayerTableName = class( TMappldXmlCommand )
protected
    Fcode                       : string;
    FtableName                  : string;
        
protected
    procedure   internalProccess(); override;

    end;

implementation

{*******************************************************************************
* internalProccess
*******************************************************************************}
procedure TCmdSetLayerTableName.internalProccess();
var
    nodes : TMapXmlNodes;
    layer : TMappldXmlLayer;

begin
    nodes := nil;
    try
        nodes := TMapXmlNodes.Create();
        nodes.loadFromSubNodes( FxmlNode );

        Fcode      := nodes.valueAsString( XML_A_code, '' );
        FtableName := nodes.valueAsString( XML_A_tableName, '' );

        if ( ( Fcode = '' ) or ( FtableName = '' ) ) then
        begin
            exit;
        end;

        layer := FxmlContext.layersByCode[ Fcode ];
        if ( layer = nil ) then
        begin
            exit;
        end;

        layer.tableName := FtableName;
    finally
        FreeAndNil( nodes );
    end;
end;

initialization

TMappldXmlCommand.registerCommandByCode( XML_CMD_SetLayerTableName, TCmdSetLayerTableName );

end.
